/**
 * @param {number[]} nums
 * @param {number} k
 * @return {void} Do not return anything, modify nums in-place instead.
 */
var rotate = function(nums, k) {
  let len = nums.length
  k = (k % len) * -1 // 最少移动次数
  nums.unshift(...nums.splice(k))
  nums.length = len
  return nums
}

console.log(rotate([1, 2, 3, 4, 5, 6, 7], 3))
